import Router from 'koa-router';
import Categroy from '../dbs/models/category'
import axios from './util/axios'
let router = new Router({prefix: '/categroy'})

router.get('/crumbs',async (ctx)=>{
  // let result = await Categroy.findOne({city: ctx.query.city.replace('市', '') || '北京'})
  let result= await axios.get('http://cp-tools.cn/categroy/crumbs',{
    params:{
      city:ctx.query.city.replace('市','') || "北京",
    }
  })

  if (result) {
    ctx.body = {
      status: true,
      areas: result.areas,
      types: result.types
    }
  } else {
    ctx.body = {
      status: false,
      areas: [],
      types: [],
      msg: '未找到数据'
    }
  }

})


export default router;
